import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import "bootstrap/dist/css/bootstrap.min.css";
import "bootstrap/dist/css/bootstrap-theme.min.css";

// import registerServiceWorker from './registerServiceWorker';

// import GradeExamineDetail from './grade/grade_control/GradeExamineDetail'
// ReactDOM.render(<GradeExamineDetail />, document.getElementById('root'));

import {GradeAnalysis, GradeControl, GradeExamine, GradeInput, GradeLack, GradeMakeUp, StudentScoreBase, GradeInputDetails, GradeDetail, GradeExamineDialog} from './grade/grade_control'
import {TeacherChooser} from "./grade/tools";
import MenuPage from './grade/MenuPage'
import ExamPlan from "./grade/grade_control/ExamPlan";

const menuMap = {
    'TeacherChooser':'教师选择框',
    'GradeControl':'成绩控制',
    GradeInputDetails:'成绩控制--录入情况',
    GradeDetail:'成绩控制--录入明细',
    GradeInput:'成绩录入管理',
    GradeExamine:'成绩录入审核',
    GradeEntry:'成绩录入审批',
    GradeExamineDialog:"成绩录入审核审批对话框",
    GradeLack:'缺考缓考管理',
    GradeMakeUp:'补考重修管理',
    StudentScoreBase:"学生成绩总库",
    ExamPlan:"生成考试计划"
};

/**
 * (\S+),
 * case '\1':\nReactDOM\.render\(<\1 />, document\.getElementById\('root'));\nbreak;
 */
if (window && window.childPage){
    window.baseUrl = window.baseUrl ||  '../../../../gradeApi/?p=';
    switch (window.childPage){
        case 'TeacherChooser':
            ReactDOM.render(<TeacherChooser semester_id={24}/>, document.getElementById('root'));
            break;
        case 'GradeAnalysis':
            ReactDOM.render(<GradeAnalysis />, document.getElementById('root'));
            break;
        case 'GradeControl':
            ReactDOM.render(<GradeControl />, document.getElementById('root'));
            break;
        case 'GradeEntry':
            ReactDOM.render(<GradeExamine check_stage="check2" />, document.getElementById('root'));
            break;
        case 'GradeExamine':
            ReactDOM.render(<GradeExamine check_stage="check1" />, document.getElementById('root'));
            break;
        case 'GradeInput':
            ReactDOM.render(<GradeInput />, document.getElementById('root'));
            break;
        case 'GradeLack':
            ReactDOM.render(<GradeLack />, document.getElementById('root'));
            break;
        case 'GradeMakeUp':
            ReactDOM.render(<GradeMakeUp />, document.getElementById('root'));
            break;
        case 'StudentScoreBase':
            ReactDOM.render(<StudentScoreBase />, document.getElementById('root'));
            break;
        case 'GradeInputDetails':
            ReactDOM.render(<GradeInputDetails />, document.getElementById('root'));
            break;
        case 'GradeDetail':
            ReactDOM.render(<GradeDetail />, document.getElementById('root'));
            break;
        case 'GradeExamineDialog':
            ReactDOM.render(<GradeExamineDialog />, document.getElementById('root'));
            break;
        case 'ExamPlan':
            ReactDOM.render(<ExamPlan />, document.getElementById('root'));
            break;
        default:
            ReactDOM.render(<MenuPage menuMap={menuMap}></MenuPage>, document.getElementById('root'));
            break;
    }
}
else {
    window.baseUrl = 'http://localhost:81/hljsfjy/gradeApi/?p=';
    if (window.parent && window.parent.childPage) {
        switch (window.parent.childPage){
            case 'TeacherChooser':
                ReactDOM.render(<TeacherChooser semester_id={24}/>, document.getElementById('root'));
                break;
            case 'GradeAnalysis':
                ReactDOM.render(<GradeAnalysis />, document.getElementById('root'));
                break;
            case 'GradeControl':
                ReactDOM.render(<GradeControl />, document.getElementById('root'));
                break;
            case 'GradeEntry':
                ReactDOM.render(<GradeExamine check_stage="check2" />, document.getElementById('root'));
                break;
            case 'GradeExamine':
                ReactDOM.render(<GradeExamine check_stage="check1" />, document.getElementById('root'));
                break;
            case 'GradeInput':
                ReactDOM.render(<GradeInput />, document.getElementById('root'));
                break;
            case 'GradeLack':
                ReactDOM.render(<GradeLack />, document.getElementById('root'));
                break;
            case 'GradeMakeUp':
                ReactDOM.render(<GradeMakeUp />, document.getElementById('root'));
                break;
            case 'StudentScoreBase':
                ReactDOM.render(<StudentScoreBase />, document.getElementById('root'));
                break;
            case 'GradeInputDetails':
                ReactDOM.render(<GradeInputDetails />, document.getElementById('root'));
                break;
            case 'GradeDetail':
                ReactDOM.render(<GradeDetail course_editable={true} dialog_args={
                    {
                        academic_year: "2030-2031-1",
                        class_name: "08级高中高职狱内侦查班",
                        course_assessment: "考试",
                        course_category: "职业技术课",
                        course_name: "国家赔偿法",
                        course_nature: "必修",
                        credits: 5,
                        exam_plan_id: 1,
                        exam_type: 0,
                        grade_count: 4,
                        teacher_name: "尹丽婷",
                        teaching_task_id:30,
                    }
                } />, document.getElementById('root'));
                break;
            case 'GradeExamineDialog':
                ReactDOM.render(<GradeExamineDialog />, document.getElementById('root'));
                break;
            case 'ExamPlan':
                ReactDOM.render(<ExamPlan />, document.getElementById('root'));
                break;
            default:
                ReactDOM.render(<MenuPage menuMap={menuMap}></MenuPage>, document.getElementById('root'));
                break;
        }
    }else{
        ReactDOM.render(<MenuPage menuMap={menuMap}></MenuPage>, document.getElementById('root'));
    }
}

// registerServiceWorker();
